package org.example.daojishi;

import java.util.Calendar;

public class HolidayDaysCalculator1 {
    private static boolean isHoliday(Calendar date) {
        int[][] holidays = {
                {Calendar.JANUARY, 1},   // 元旦
                // 春节（农历正月初一）
                {Calendar.FEBRUARY, 12},
                {Calendar.FEBRUARY, 13},
                {Calendar.FEBRUARY, 14},
                {Calendar.FEBRUARY, 15},
                {Calendar.FEBRUARY, 16},
                {Calendar.FEBRUARY, 17},
                // 清明节（农历清明节）
                {Calendar.APRIL, 4},
                {Calendar.APRIL, 5},
                {Calendar.APRIL, 6},
                // 劳动节
                {Calendar.MAY, 1},
                {Calendar.MAY, 2},
                {Calendar.MAY, 3},
                // 端午节（农历五月初五）
                {Calendar.MAY, 30},
                {Calendar.MAY, 31},
                {Calendar.JUNE, 1},
                // 中秋节（农历八月十五）
                {Calendar.SEPTEMBER, 10},
                {Calendar.SEPTEMBER, 11},
                {Calendar.SEPTEMBER, 12},
                // 国庆节
                {Calendar.OCTOBER, 1},
                {Calendar.OCTOBER, 2},
                {Calendar.OCTOBER, 3},
                {Calendar.OCTOBER, 4},
                {Calendar.OCTOBER, 5},
                {Calendar.OCTOBER, 6},
                {Calendar.OCTOBER, 7}
        };
        for (int i = 0; i < holidays.length; i++) {
            int month = holidays[i][0];
            int day = holidays[i][1];
            if (date.get(Calendar.MONTH) == month && date.get(Calendar.DAY_OF_MONTH) == day) {
                return true;
            }
        }
        // 添加判断周六日的逻辑
        int dayOfWeek = date.get(Calendar.DAY_OF_WEEK);
        return dayOfWeek == Calendar.SATURDAY || dayOfWeek == Calendar.SUNDAY;
    }

    public static void main(String[] args) {
        Calendar today = Calendar.getInstance();
        int days = 0;
        while (!isHoliday(today)) {
            days++;
            today.add(Calendar.DAY_OF_MONTH, 1);
        }
        System.out.println("Days until next holiday or weekend: " + days);
    }
}